// src/router/index.js
import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/Home.vue'
import About from '@/views/About.vue'
import NotFound from '@/views/NotFound.vue'
import Itfdoc from '@/views/sip/itfdoc/index.vue'
import Siplog from '@/views/sip/siplog/index.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Itfdoc,
    meta: { title: '首页' }
  },
  {
    path: '/about',
    name: 'About',
    component: About,  // 注意：这里组件名和导入名不一致，是否应为About？
    meta: { title: '关于' }
  },
  {
    path: '/itfdoc',
    name: 'ItfDoc',
    component: Itfdoc,
    meta: { title: '接口档案' }
  },
  {
    path: '/siplog',
    name: 'SipLog',
    component: Siplog,
    meta: { title: '系统集成平台日志' }
  },
  {
    path: '/:pathMatch(.*)*',
    name: 'NotFound',
    component: NotFound
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

router.beforeEach((to, from, next) => {
  document.title = '系统集成平台'
  next()
})

export default router